<?php
    header('Content-type:text/html;charset=utf-8');
    $file = @file("./data/chat.dat") or die("{code:1,data:{}}");
    $rtn = "{code:0,data:{";
    $count = 0;
    foreach($file as $line){
        // $rtn .= trim($line);
        $expline = explode(":",trim($line));
        $rtn .= $expline[0];
        $rtn .= ":";
        for($i=2;$i<count($expline);++$i){
            if($i !== 2){
                $rtn .= ":";
            }
            $rtn .= $expline[$i];
        }
        $count++;
        if($count < count($file)){
            $rtn .= ",";
        }
    }
    $rtn .= "}}";
    echo $rtn;
?>